package Jedis.JedisExample.Dao;

import Jedis.JedisExample.domain.Province;
import Jedis.JedisExample.util.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class ProvinceDao {
   //1. 声明成员变量 jdbctemplate
    private JdbcTemplate template=new JdbcTemplate(JDBCUtils.getDataSource());

    public List<Province> findAll(){
      //1.定义sql
        String sql="select * from province";
        //2.执行sql
        List<Province> list = template.query(sql, new BeanPropertyRowMapper<Province>(Province.class));
        return list;
    }
}
